import { createRouter, createWebHistory } from 'vue-router'
import { nextTick } from 'vue'
const routes = [
  {
    path: '/',
    component: () => import('@/views/HomeView.vue')
  },
  {
    path: '/detail/:id',
    component: () => import('@/views/DetailOne.vue')
  },
  {
    path: '/all',
    component: () => import('@/views/AllView.vue')
  },
  {
    path: '/user',
    component: () => import('@/views/UserView.vue')
  },
  {
    path: '/login',
    component: () => import('@/views/loginView.vue')
  }
]

const router = createRouter({
  history: createWebHistory(),
  routes,
})
router.afterEach((to, from) => {
  nextTick(() => {
    window.scrollTo({
      top: 0,
      behavior: 'smooth'
    })
  })
})
export default router
